package flutterdemo.service;

import flutterdemo.dao.MessageDao;
import flutterdemo.model.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * 消息服务
 */
@Service
public class MessageService {
    @Autowired
    private MessageDao messageDao;

    /**
     * 上传消息
     * 
     * @param messageContent
     * @param imageUrlList
     * @param userType
     */
    public void uploadMessage(
            String messageContent,
            String imageUrlList,
            Long userType) throws IOException {
        messageDao.save(new Message(messageContent, imageUrlList, userType, new Date()));
    }

    /**
     * 删除全部消息
     */
    public void deleteAllMessage() throws IOException {
        messageDao.deleteAll();
    }

    /**
     * 查询全部消息
     */
    public List<Message> queryAllMessage() throws IOException {
        return messageDao.queryAll();
    }
}
